/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FrmEntero.java
 *
 * Created on 01-12-2014, 08:52:31 AM
 */
package presentacion;

/**
 *
 * @author Estudiante
 */
import Negocio.Entero;
import javax.swing.JOptionPane;
public class FrmEntero extends javax.swing.JFrame {

    /** Creates new form FrmEntero */
    public FrmEntero() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        btnPar = new javax.swing.JButton();
        txNumero = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        btnFactorial = new javax.swing.JButton();
        btnInvertir = new javax.swing.JButton();
        btnPrimo = new javax.swing.JButton();
        btnCapicua = new javax.swing.JButton();
        btnEliminar = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        btnPar.setText("Par");
        btnPar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnParActionPerformed(evt);
            }
        });

        jLabel1.setText("intrduzca un numero");

        btnFactorial.setText("Factorial");
        btnFactorial.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnFactorialActionPerformed(evt);
            }
        });

        btnInvertir.setText("Invertir");
        btnInvertir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnInvertirActionPerformed(evt);
            }
        });

        btnPrimo.setText("Primo");
        btnPrimo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPrimoActionPerformed(evt);
            }
        });

        btnCapicua.setText("Capicua");
        btnCapicua.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCapicuaActionPerformed(evt);
            }
        });

        btnEliminar.setText("Eliminar Primo");
        btnEliminar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEliminarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(36, 36, 36)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnEliminar)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(btnPar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnFactorial)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnPrimo)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnInvertir)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnCapicua))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addGap(59, 59, 59)
                        .addComponent(txNumero, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(50, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(42, 42, 42)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(txNumero, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(35, 35, 35)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnPar)
                    .addComponent(btnFactorial)
                    .addComponent(btnPrimo)
                    .addComponent(btnInvertir)
                    .addComponent(btnCapicua))
                .addGap(18, 18, 18)
                .addComponent(btnEliminar)
                .addContainerGap(139, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnParActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnParActionPerformed
        // TODO add your handling code here:
        Entero ObjEntero = new Entero();
        ObjEntero.setNum(Integer .parseInt(this.txNumero.getText()));
        if(ObjEntero.Par())
        {
            JOptionPane.showMessageDialog(null,"El numero es par");
        }
        else
        {
            JOptionPane.showMessageDialog(null,"El numero no es par");
        }
    }//GEN-LAST:event_btnParActionPerformed

    private void btnInvertirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnInvertirActionPerformed
        // TODO add your handling code here:
        Entero ObjEntero = new Entero();
        ObjEntero.setNum(Integer .parseInt(this.txNumero.getText()));
        JOptionPane.showMessageDialog(null,ObjEntero.Invertir());
    }//GEN-LAST:event_btnInvertirActionPerformed

    private void btnPrimoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPrimoActionPerformed
        // TODO add your handling code here:
        Entero ObjEntero = new Entero();
        ObjEntero.setNum(Integer .parseInt(this.txNumero.getText()));
        if(ObjEntero.Primo())
        {
            JOptionPane.showMessageDialog(null,"El numero es primo");
        }
        else
        {
            JOptionPane.showMessageDialog(null,"El numero no es primo");
        }
    }//GEN-LAST:event_btnPrimoActionPerformed

    private void btnFactorialActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFactorialActionPerformed
        // TODO add your handling code here:
        Entero ObjEntero = new Entero();
        ObjEntero.setNum(Integer .parseInt(this.txNumero.getText()));
        JOptionPane.showMessageDialog(null,ObjEntero.Factorial());
    }//GEN-LAST:event_btnFactorialActionPerformed

    private void btnCapicuaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCapicuaActionPerformed
        // TODO add your handling code here:
        Entero ObjEntero = new Entero();
        ObjEntero.setNum(Integer .parseInt(this.txNumero.getText()));
        JOptionPane.showMessageDialog(null,ObjEntero.Capicua());
    }//GEN-LAST:event_btnCapicuaActionPerformed

    private void btnEliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEliminarActionPerformed
        // TODO add your handling code here:
        Entero ObjEntero = new Entero();
        ObjEntero.setNum(Integer .parseInt(this.txNumero.getText()));
        JOptionPane.showMessageDialog(null,ObjEntero.EliminarDigitoPrimos());
    }//GEN-LAST:event_btnEliminarActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new FrmEntero().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCapicua;
    private javax.swing.JButton btnEliminar;
    private javax.swing.JButton btnFactorial;
    private javax.swing.JButton btnInvertir;
    private javax.swing.JButton btnPar;
    private javax.swing.JButton btnPrimo;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JTextField txNumero;
    // End of variables declaration//GEN-END:variables
}
